import uniRequest1 from 'uni-request';
// let baseURL='http://175.24.68.5:9999'; //接口地址
let baseURL='http://wx.hidaoyou.com';
// let baseURL='http://youdaoyou.com';
function myRequest(options){
	let headers = {}
	var Token = uni.getStorageSync('token');
	// var Token = "65600c0f4388a5681949c6ff58e598cbae4760b069d27d812e8c65cd44b86ebc";
	headers['XX-Device-Type'] = 'wxapp';
	headers['XX-Token'] = Token;
	headers["XX-Api-Version"] = "1.0";
	headers["Content-Type"] = "application/json";
	// console.log(options);
	return new Promise((res,rej)=>{
		uni.request({
			url:baseURL + options.url,
			method:options.method || 'GET',
			data:options.data,
			header:headers,
			success(data) {
				//console.log(options.url);
				//console.log(options.data);
				//登录过期清空本地缓存token和用户信息
				if(data.data.code === 10002){
					uni.removeStorage({
						key:'toklen',   //根据键值移除对应位置的缓存数据
					})
					uni.removeStorage({
						key:'userInfo',   //根据键值移除对应位置的缓存数据
					})
				}
				res(data);
			},
			fail() {
				alert(rej());
			}
		})
	})
}
export default myRequest;